var classesGrid = Ext.create('Ext.grid.Panel', {
    title: '待开班班级列表',
    store: classesListStore,
    selModel: classesGridCheckBox,
    dockedItems: [{
        xtype: 'toolbar',
        items: [{
            text: '添加',
            tooltip: '添加班级',
            itemId: 'addClassesButton',
            icon: 'static/images/icons/fam/add.gif',
            listeners: {
                click: function () {
                    addClassesButtonClick();
                }
            }
        }, '-', {
            text: '删除',
            tooltip: '删除班级',
            itemId: 'deleteClassesButton',
            icon: 'static/images/icons/fam/delete.gif',
            listeners: {
                click: function () {
                    deleteClassesButtonClick();
                }
            }
        }]
    }],
    columns: [new Ext.grid.RowNumberer(), //显示行号
        {
            text: '名称',
            //width: 230,
            flex: 1,
            align: 'center',
            dataIndex: 'name',
            hideable: false,
        }, {
            header: '状态',
            align: 'center',
            width: 180,
            dataIndex: 'statusName'
        }, {
            text: '操作',
            align: 'center',
            sortable: false,
            xtype: 'actioncolumn',
            width: 140,
            items: [{
                icon: 'static/images/icons/fam/look.ico',
                tooltip: '查看详情',
                handler: function (grid, rowIndex, colIndex, actionItem, event, record, row) {
                    seeDetailClick(record);
                }
            }, '-', {
                icon: 'static/images/icons/fam/plan.ico',
                tooltip: '手动完成开班',
                handler: function (grid, rowIndex, colIndex, actionItem, event, record, row) {
                    manualOpenClassesClick(record);
                }
            }]
        }]
});

//用来显示班级人员信息的Grid
var classesMemberGrid = Ext.create('Ext.grid.Panel', {
    store: classesMemberGridStore,
    columns: [new Ext.grid.RowNumberer(), // 显示行号
        {
            text: '昵称',
            flex: 1,
            dataIndex: 'name',
            sortable: false
        }
    ],
    dockedItems: [{
        xtype: 'toolbar',
        items: [{
            text: '添加',
            tooltip: '添加班级成员',
            itemId: 'addButton',
            icon: 'static/images/icons/fam/add.gif',
            listeners: [{
                click: function () {
                    chooseClassesMemberAddGridStore.reload();
                    chooseClassesMemberAddGridCheckBox.deselectAll();
                    chooseClassesMemberAddGridWin.show();
                }
            }]
        }, '-', {
            text: '删除',
            tooltip: '删除班级成员',
            itemId: 'deleteButton',
            icon: 'static/images/icons/fam/delete.gif',
            listeners: [{
                click: function () {
                    var selectArray = classesMemberGridCheckBox.getSelection();
                    if (selectArray.length == 0)
                        Ext.Msg.alert("Error", "请选择要删除的班级成员！");
                    else
                        classesMemberGridStore.remove(selectArray);
                }
            }]
        }]
    }],
    selModel: classesMemberGridCheckBox
});

//用于给添加班级成员选择班级成员的grid
var chooseClassesMemberAddGrid = Ext.create('Ext.grid.Panel', {
    store: chooseClassesMemberAddGridStore,
    columns: [new Ext.grid.RowNumberer(), // 显示行号
        {
            text: '昵称',
            flex: 1,
            dataIndex: 'realName',
            sortable: false
        }, {
            text: '用户名',
            flex: 1,
            dataIndex: 'userName',
            sortable: false
        }, {
            text: '已属班级数量',
            dataIndex: 'hasClassesCount'
        }
    ],
    selModel: chooseClassesMemberAddGridCheckBox
});

//用于显示班级创建人的选择Grid
var classesChooseClassesCreaterGrid = Ext.create('Ext.grid.Panel', {
    header: false,
    store: classesChooseClassesCreaterGridStore,
    columns: [new Ext.grid.RowNumberer(), //显示行号
        {
            text: '名称',
            flex: 1,
            align: 'center',
            dataIndex: 'realName',
            hideable: false,
        }, {
            text: '用户名',
            flex: 1,
            dataIndex: 'userName',
            sortable: false
        }, {
            text: '负责的班级数量',
            flex: 1,
            align: 'center',
            dataIndex: 'hasClassesCount',
            hideable: false
        }
    ],
    listeners: [{
        itemdblclick: function (view, record, item, index, e, eOpts) {
            classesProcessForm.down('#toDirector').setValue(record.data.realName);
            classesProcessForm.down('#toDirector').toDirector = record.data.id;
            classesChooseClassesCreaterGridWin.close();
        }
    }]
});